import { reqAllGoodsData } from '@/api/index'

const state = {
  allGoodsData: []
}

const mutations = {
  RECEIVE_ALLGOODSDATA (state, allGoodsData) {
    state.allGoodsData = allGoodsData
  }
}
const actions = {
  async getAllGoodsData ({ commit }) {
    const result = await reqAllGoodsData()
    if (result.code === 200) {
      commit('RECEIVE_ALLGOODSDATA', result.data)

    }
  }
}
const getters = {
  allGoodsList(state){
    const obj = state.allGoodsData.result || {}
    return obj.data || []
  }
}

export default {
  state,
  mutations,
  actions,
  getters
}
